package ar.com.mooral.pojo;

import java.util.Vector;

public class AlarmPojo extends BasePojo {


	private Vector times;
	
	protected void initialize() {
		times = new Vector();
	}


	public void parseHours() {
		if (get("horas") != null && !get("horas").equals("")) {
			String[] tmp = ((String)get("horas")).split(",");
			for (int i = 0; i < tmp.length; i++) {
				times.add(tmp[i]);
			}
		}
	}

	public void setId(String id){
		put("id", id);
	}
	
	public String getUris(){
		if (get("uris") != null) {
			return get("uris");
		} else {
			return "";
		}
	}

	public void setUris(String uris){
		put("uris", uris);
	}
	
	public void setDate(String date){
		put("fecha_inicio", date);
	}

	public String getDate(){
		if (get("fecha_inicio") != null) {
			return get("fecha_inicio");
		} else {
			return "";
		}
	}


	public void setRepeatQuantity(String quantity){
		put("repetir_cantidad", quantity);
	}

	public void setRepeatUnit(String unit) {
		put("repetir_unidad", unit);
	}
	

	public String getRepeatQuantity(){
		if (get("repetir_cantidad") != null) {
			return get("repetir_cantidad");
		} else {
			return "";
		}
	}

	public String getRepeatUnit() {
		if (get("repetir_unidad") != null) {
			return get("repetir_unidad");
		} else {
			return "";
		}
	}

	
	public void setTime(int hour, int minute) {
		String h;
		String m;
		if (minute <= 9) {
			m = "0" + Integer.toString(minute);
		} else {
			m = Integer.toString(minute);
		}
		
		if (hour <= 9) {
			h = "0" + Integer.toString(hour);
		} else {
			h = Integer.toString(hour);
		}
		
		times.add(h + ":" + m);
	}
	
	public void removeHour(String hour) {
		
		for (int i = 0; i < times.size(); i++) {
			String s = (String)times.get(i);
			if (s.equals(hour)) {
				times.remove(i);
				break;
			}
		}
	}
	
	public String getHours() {
		String r = "";
		for (int i = 0; i < times.size(); i++) {
			r += times.get(i);
			if ((i+1) < times.size()) {
				r += ","; 	
			}
		}
		return r;
	}

	
	public void setMedicationId(String medication) {
		put("medicacion_id", medication);
	}
	
}
